package filter;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@WebFilter("/filer01")
public class Filter01 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println("开放前");


        //设置编码
        ((HttpServletRequest) servletRequest).setCharacterEncoding("utf-8");

        //开放，转发请求
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("开放后");

    }

    @Override
    public void destroy() {

    }
}
